package com.glsc.ngateway.platform.repo.costallocation;

import com.glsc.ngateway.platform.domain.costallocation.CostAllocationTask;
import com.glsc.ngateway.platform.domain.costallocation.DepCostAllocation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CostAllocationTaskRepo extends JpaRepository<CostAllocationTask, Long>, JpaSpecificationExecutor<CostAllocationTask> {


    @Query(value = "select u  from CostAllocationTask u where u.taskName = :taskName " +
            "and u.depGradeOneId = :depGradeOneId and u.systemClassNo = :systemClassNo")
    List<CostAllocationTask> queryByTaskNameAndDepOneIdAndSystemNo(@Param("taskName") String taskName,
                                                                   @Param("depGradeOneId") String depGradeOneId,
                                                                   @Param("systemClassNo") String systemClassNo);

    @Query(value = "select u  from CostAllocationTask u where u.taskName = :taskName")
    List<CostAllocationTask> queryByTaskName(@Param("taskName") String taskName);
    @Query(value = "select u  from CostAllocationTask u where u.taskName = :taskName " +
            "and u.vcIp = :vcIp " +
            "and u.systemClassNo = :systemClassNo")
    List<CostAllocationTask> queryByTaskNameAndSystemNoAndIp(@Param("taskName") String taskName,
                                             @Param("systemClassNo") String systemClassNo,
                                                             @Param("vcIp") String vcIp);

    @Query(value = "select u  from CostAllocationTask u where u.taskName = :taskName " +
            "and u.startDate = :startDate " +
            "and u.endDate = :endDate order by u.id asc")
    List<CostAllocationTask> queryBytaskNameAndstartDateAndendDate(@Param("taskName") String taskName,
                                      @Param("startDate") String startDate,
                                      @Param("endDate") String endDate);

    @Query(value = "select u  from CostAllocationTask u where u.taskName = :taskName " +
            "and u.startDate = :startDate " +
            "and u.id = :id " +
            "and u.endDate = :endDate order by u.id asc")
    List<CostAllocationTask> queryByIDAndTaskNameAndstartDateAndendDate(@Param("id") Long id,
                                                                        @Param("taskName") String taskName,
                                                                   @Param("startDate") String startDate,
                                                                   @Param("endDate") String endDate);



}
